<template>
  <tm-app ref="app">
    <!-- #ifndef H5 -->
    <tm-navbar :title="data.title"></tm-navbar>
    <!-- #endif -->
    <personList :setList="data.listInfo" @btnClick="goMenu"></personList>
  </tm-app>
</template>

<script lang="ts" setup>
import { groupListData } from '../../relation/config/config'
import personList from '../../relation/components/personList.vue'
import { onLoad } from '@dcloudio/uni-app'
import { reactive } from 'vue'
const data = reactive<any>({
  listInfo: [],
  title: '',
  key: '',
  icon: ''
})
onLoad(query => {
  if (query && query.item) {
    let item = JSON.parse(query.item)
    data.title = item.label
    data.key = item.key
    data.icon = item.icon
    let arr: {
      id: any
      label: any
      itemType: any
      icon: any
      isShow: boolean
    }[] = []
    groupListData.forEach(element => {
      element.itemType = item.itemType
      arr.push(element)
    })
    data.listInfo = arr
  }
})
function goMenu(item: {
  id: any
  label: any
  key: any
  icon: any
  itemType: any
}) {
  const params = {
    key: data.key,
    title: data.title,
    label: item.label,
    icon: '',
    itemType: item.itemType
  }
  if (item.id === 'member') {
    //个人
    uni.navigateTo({
      url: '/pages/relation-pages/member/memberList?item=' + JSON.stringify(params)
    })
  } else {
    if (item.label === '部门') {
      //如果是部门
      uni.navigateTo({
        url: '/pages/relation-pages/group/departList?item=' + JSON.stringify(params)
      })
    } else {
      uni.navigateTo({
        url: '/pages/relation-pages/group/groupIndex?item=' + JSON.stringify(params)
      })
    }
  }
}
</script>

<style scoped></style>
